using UnityEngine;
using QFramework;
using System.Collections.Generic;

namespace ProjectSurvivor
{
    public partial class BasketballAbility : ViewController
    {
        private List<Ball> mBalls = new List<Ball>();
        void Start()
        {

            void CreateBall()
            {
                mBalls.Add(Ball.Instantiate()
                    .SyncPosition2DFrom(this)
                    .Show());
            }

            Global.BasketBallCount.Or(Global.AdditionFlyThingCount).Register(() =>
            {
                var ballCount2Create = Global.BasketBallCount.Value + Global.AdditionFlyThingCount.Value - mBalls.Count;
                if (mBalls.Count < Global.BasketBallCount.Value + Global.AdditionFlyThingCount.Value)
                {
                    CreateBall();
                }
            }).UnRegisterWhenGameObjectDestroyed(gameObject);

            CreateBall();

        }
    }
}
